var serial = function()
{
    
    var that = this;
    this.list = [];
    
    this.add = function(f)
    {
        this.list.push(f);
        return this;
    };
    
    this.clear = function()
    {
        this.list = [];
        return this;
    };
    this.run = function(data, index)
    {
        if(isNaN(index)){
            index = 0;
        }
        var sum = list.length;
        if(index == sum){
            that.list = [];
            return false;
        }
        else{
            that.list[index](
                data,
                function(){
                    that.run(data, ++index);
                }
            );
        }
    };
};

module.exports = serial;